home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / Text / LAGATextEdit.cp < prev    next >
Encoding:
Text File  |  1996-06-30  |  4.4 KB  |  136 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LAGATextEdit.cp
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant Text Edit Field
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGATextEdit.h            <- double-click + Command-D to see class declaration
  27. //
  28. //    LAGATextEdit is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        Text Edit field. It is designed to work effectively with a class like LAGAIndexTab.
  30. //        In an index tab, a Text Edit Field can be present but in another Index Tab, and should
  31. //        therefore not be selected when the user presses the “Tab” key. Also if the Index Tab is
  32. //        changed and a Text Entry Field is revealed it should be selected. LAGATextEdit handles
  33. //        all these cases.
  34. //        LAGATextEdit keeps its own background in white, whatever the window background may be.
  35. //
  36. //        Version : 1.2
  37. //
  38. //        Change History (most recent first, date in US form : mm/dd/yy):
  39. //
  40. //                        06/30/96    ca        Public release of version 1.2
  41. //                        06/04/96    ca        Added RegisterClass method to ease registry
  42. //                                                        Increased version to 1.2
  43. //                        05/20/96    ca        Increased version to 1.1
  44. //                                                        Added "on the fly" constructor
  45. //                                                        Added change history
  46. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  47. //                                                        (version 1.0)
  48. //
  49. //        To Do:
  50. //
  51.  
  52. #include "LAGATextEdit.h"
  53. #include <UDrawingState.h>
  54.  
  55. //    begin    <06/04/96    ca>
  56. void LAGATextEdit::RegisterClass ()
  57.  
  58. {
  59.     URegistrar::RegisterClass(LAGATextEdit::class_ID, (ClassCreatorFunc)LAGATextEdit::CreateAGATextEditStream);
  60. }
  61. //    end    <06/04/96    ca>
  62.  
  63. LAGATextEdit* LAGATextEdit::CreateAGATextEditStream (LStream *inStream)
  64.  
  65. {
  66.     return(new LAGATextEdit(inStream));
  67. }
  68.  
  69. //-------Constructors-------------------------------------------------------------------------------------------------
  70.  
  71. LAGATextEdit::LAGATextEdit (LStream *inStream) : LTextEdit (inStream)
  72.  
  73. {
  74. }
  75.  
  76. LAGATextEdit::LAGATextEdit (const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo,
  77.                                                         Uint16 inTextAttributes, ResIDT inTextTraitsID)
  78.                                                     : LTextEdit(inPaneInfo, inViewInfo, inTextAttributes, inTextTraitsID)
  79. {
  80. }
  81.  
  82. Boolean LAGATextEdit::ObeyCommand (CommandT inCommand, void* ioParam)
  83.  
  84. {
  85.     Boolean cmdHandled = true;
  86.  
  87.     switch (inCommand)
  88.         {
  89.             case msg_TabSelect    :            //    Often LAGATextEdit items can be in tab index views and we need to be seen to be selected
  90.                         if (!IsEnabled())
  91.                             cmdHandled = false;
  92.                         else
  93.                             if (mSuperView != nil)
  94.                                 {
  95.                                     Rect frame;
  96.                                     Rect revealedRect;
  97.                                 
  98.                                     CalcPortFrameRect(frame);
  99.                                     mSuperView->GetRevealedRect(revealedRect);
  100.                                     cmdHandled = ::SectRect(&revealedRect, &frame, &revealedRect);
  101.                                 }
  102.                         if (!cmdHandled)
  103.                             break;                    //    else fall thru to default case
  104.             default:
  105.                         cmdHandled = LTextEdit::ObeyCommand(inCommand, ioParam);
  106.                         break;
  107.         }
  108.     
  109.     return cmdHandled;
  110. }
  111.  
  112. void LAGATextEdit::SpendTime (const EventRecord    &inMacEvent)
  113.  
  114. {
  115.     if (FocusDraw() & IsVisible() & HasAttribute(textAttr_Selectable))
  116.         {
  117.             ::TEIdle(mTextEditH);
  118.         }
  119.     else
  120.         SwitchTarget(GetSuperCommander());
  121. }
  122.  
  123. void LAGATextEdit::DrawSelf ()
  124.  
  125. {
  126.     Rect frame;
  127.     StColorState saveColors;
  128.  
  129.     CalcLocalFrameRect(frame);
  130.     
  131.     ::BackColor(whiteColor);
  132.     ::EraseRect(&frame);
  133.     
  134.     LTextEdit::DrawSelf();
  135. }
  136.